<template>
	<view class="box screen-all flex">
		<head-navigation></head-navigation>
		<view class="top-view flex center">
			<view class="top-con flex row aCenter">
				<text class="rmb">¥</text>
				<text class="price-text">{{balance}}</text>
			</view>
			<text class="top-text-hint">可提现金额(元)</text>
			
			<!-- 提现记录 -->
			<view class="jilu-btn flex center" @click="goList">
				提现记录
			</view>
		</view>
		
		<!-- 提现框 -->
		<view class="con-view flex">
			<view class="con-top-view flex row aCenter">
				<text class="flex-1">提现方式：</text>
				<image class="icon-bl" src="../../static/blbl.png"></image>
				<text class="tx-ka">提现到银行卡</text>
				<image class="icon-edit" src="../../static/edit_bl.png" @click="toBindBank()"></image>
			</view>
			<text class="tx-hint">提现金额</text>
			<view class="input-view flex row aCenter">
				<text class="tx-rmb">¥</text>
				<input class="tx-input flex-1" v-model="price" type="number" placeholder="请输入提现金额" />
				<view class="tx-btn flex center" @click="allTx">全部提现</view>
			</view>
			
		</view>
		
		
		<!-- 提现按钮 -->
		<view class="tx-btn-view flex center" @click="tixian">
			立即提现
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				price: '',
				
				balance: "0.00",
				bank_name: "",
				bank_number: "",
				bank_username: "",
				id: 0,
			}
		},
		onLoad() {
			// this.getInfo();
		},
		onShow() {
			this.getInfo();
		},
		methods: {
			getInfo  () {
				// api/Talent/withdrawal
				let params = {
					token: uni.getStorageSync("token"),
				}
				console.log(params);
				this.$request("api/Talent/withdrawal", params)
					.then(({ code, msg, data, time }) => {
						console.log(code, msg, data);
						if(code == 1){
							this.balance = data.balance;
							this.bank_name = data.bank_name;
							this.bank_number = data.bank_number;
							this.bank_username = data.bank_username;
							this.id = data.id;
						}else{
							
						}
					}).catch((e) => {
						console.log(e);
					});
			},
			allTx () {
				this.price = this.balance;
			},
			tixian () {
				if(!this.bank_number){
					//银行卡号胃口 先去绑定银行卡
					this.toBindBank();
					return ;
				}
				// api/Talent/withdrawalSave
				if(!this.price){
					uni.showToast({
						title: '请输入提现金额', icon: 'none',
					})
					return ;
				}
				if(parseFloat(this.price) > parseFloat(this.balance)){
					uni.showToast({
						title: '可提现金额不足', icon: 'none',
					})
					return ;
				}
				let params = {
					token: uni.getStorageSync("token"),
					money: this.price,
				}
				console.log(params);
				this.$request("api/Talent/withdrawalSave", params)
					.then(({ code, msg, data, time }) => {
						console.log(code, msg, data);
						uni.showToast({
							title: msg, icon: 'none',
						})
						if(code == 1){
							this.price = '';
							this.getInfo();
							
						}else{
							
						}
					}).catch((e) => {
						console.log(e);
					});
			},
			goList () {
				// 我的钱包提现记录
				uni.navigateTo({url:"wallet-list"});
			},
			toBindBank () {
				// 我的钱包提现记录
				uni.navigateTo({url:"bind-bank"});
			},
		}
	}
</script>

<style scoped lang="scss">
	.box {
		background-color: #010B24;
	}
	.top-view {
		width: 100%;
		height: 300rpx;
		background-image: linear-gradient(to bottom, #9A75EF, #613ABD);
		border-bottom-left-radius: 50rpx;
		border-bottom-right-radius: 50rpx;
		color: #FFF;
		position: relative;
		z-index: 2;
	}
	.top-con {
		margin-top: -100rpx;
	}
	.price-text {
		font-size: 32rpx;
	}
	.rmb {
		font-size: 24rpx;
		margin-top: 7rpx;
	}
	.top-text-hint {
		font-size: 28rpx;
	}
	.jilu-btn {
		width: 153rpx;
		height: 61rpx;
		border-top-left-radius: 32rpx;
		border-bottom-left-radius: 32rpx;
		border: 1rpx solid #FFFFFFBB;
		border-right: 0;
		font-size: 26rpx;
		color: #FFF;
		position: absolute;
		top: 50rpx;
		right: 0;
		&:active {
			background-color: #00000011;
		}
	}
	.con-view {
		width: 690rpx;
		height: 300rpx;
		background-color: #FFF;
		border-radius: 20rpx;
		margin-left: 30rpx;
		margin-top: -100rpx;
		z-index: 7;
		padding: 0 50rpx;
	}
	.con-top-view {
		padding: 38rpx 0;
	}
	.icon-bl {
		width: 38rpx;
		height: 30rpx;
	}
	.icon-edit {
		width: 23rpx;
		height: 27rpx;
	}
	.tx-ka {
		font-size: 28rpx;
		color: #666666;
		margin: 0 12rpx;
	}
	.tx-hint {
		font-size: 28rpx;
		color: #666666;
		margin-top: 12rpx;
	}
	.input-view {
		padding-top: 38rpx;
	}
	.tx-rmb {
		font-size: 24rpx;
		color: #3F536E;
		margin-right: 12rpx;
	}
	.tx-input {
		font-size: 28rpx;
		color: #010B24;
	}
	.tx-btn {
		width: 159rpx;
		height: 57rpx;
		background-color: #BA72F8;
		border-radius: 29rpx;
		font-size: 26rpx;
		color: #FFF;
	}
	.tx-btn-view {
		font-size: 28rpx;
		color: #FFF;
		width: 690rpx;
		height: 98rpx;
		background-color: #9637E6;
		border-radius: 50rpx;
		margin-left: 30rpx;
		margin-top: 380rpx;
	}
</style>
